package com.quanyan.place.web;

import com.quanyan.api.APIResponse;
import com.quanyan.place.entity.apireq.ReqSearchTargetCheckVo;
import com.quanyan.place.service.TargetCheckService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liuyaoxin on 2016/6/16.
 */

@RestController
@RequestMapping("/admin/api/place/targetCheck")
public class TargetCheckController {

    @Autowired
    TargetCheckService targetCheckService;

    private Logger logger = LoggerFactory.getLogger(TargetCheckController.class);

    /*
    获取登录用户的考核指标列表
    */
    @RequestMapping(value="/getTargetCheckList",method = RequestMethod.POST)
    public APIResponse<?> getTargetCheckList(@RequestBody ReqSearchTargetCheckVo vo){
        return targetCheckService.getTargetCheckList(vo);
    }
/*
    录入下级考核指标
    */
    @RequestMapping(value="/importTargetCheckList",method = RequestMethod.POST)
    public APIResponse<?> importTargetCheckList(@RequestBody List<ReqSearchTargetCheckVo> reqSearchTargetCheckVo){

        ReqSearchTargetCheckVo vo=new ReqSearchTargetCheckVo();
        vo.setListVo(reqSearchTargetCheckVo);
       targetCheckService.importTargetCheckList(vo);
        return APIResponse.returnSuccess();
    }


    /*
  查找下属成员
   */
    @RequestMapping(value="/getLowLevelList",method = RequestMethod.GET)
    public APIResponse<?> getLowLevelList(@RequestParam(value = "id",required = false) Integer id,Integer type){
        return targetCheckService.getLowLevelList(id,type);

    }

    /**
     * 通过主键ID获取下级指标信息
     * @param id
     * @return
     */
    @RequestMapping(value="/getLowLevelTargetByid",method = RequestMethod.GET)
    public APIResponse<?> getLowLevelTargetByid(@RequestParam(value = "id",required = false) Integer id){
        return APIResponse.returnSuccess(targetCheckService.getLowLevelTargetByid(id));
    }

    @RequestMapping(value="/getLowLevelTargetByUid",method = RequestMethod.GET)
    public APIResponse<?> getLowLevelTargetByUid(@RequestParam(value = "uid",required = false) Integer uid){
        return APIResponse.returnSuccess(targetCheckService.getLowLevelTargetByUid(uid));
    }


}
